<script>
    function popReport(){
        var url_report = '<?php echo site_url('report');?>';
        OpenPop(url_report, 650, 990);
    }
</script>
<div class="row">
	<div class="col-sm-12" style="width: 99%;">
		<div class="nest" id="treeClose">
			<div class="title-alt" style="position: relative">
				<h6>Trang chủ</h6>
                <button class="btn btn-success" style="position: absolute;top: 10px;right: 15px" onclick="popReport()">XUẤT BÁO CÁO</button>
			</div>

			<div class="body-nest" id="tree" style="min-height: 490px">
				<div class="row">
				<!-- -->		
					<?php $att = array('method'=> 'get', 'id' => 'contact-form', 'class' => 'form-horizontal'); echo form_open('', $att);?>
					<fieldset style="margin-bottom: 20px;">
						<div class="control-group">
							<div class="controls">
								<select style="width: 27%;float: left;margin:0 10px 0 20px;" class="form-control" name="province" id="province"><option value="0" >Chọn tỉnh thành phố</option>
								<?php foreach ( $listprovince AS $el=>$le ){ ?>
								<option <?php if( @$provinceid == $le->provinceid ){ echo 'selected="selected"';} ?> value="<?php echo $le->provinceid;?>"><?php echo $le->name;?></option>
								 <?php } ?>
								</select>                                                </div>
								<div class="controls">
									<select style="width: 27%;float: left;margin:0 10px 0 0" class="form-control" name="district" id="district">
										<option value="" selected="selected">Chọn quận huyện</option>
									</select>
								</div>
								<div class="controls" style="width: 27%;float: left;margin-right:10px;">
                                    <input placeholder="Từ khóa tìm kiếm" type="text" class="form-control s" value="<?php echo @$s ? @$s : $this->input->post('s')?>" name="s" id="s" />
								</div>
								<div class="form-actions" style="margin:0 0 0 5px;float: left;">
									<button type="submit" class="btn btn-primary">Đồng ý</button>
								</div>
								
						</div>
					  
						
					</fieldset>
				</form>
				
				
				
				<!-- -->
					<div class="col-sm-12">
						<ul id="browser" class="filetree treeview">
							<?php foreach($data AS $el=>$le):?>
                                <li class="collapsable"><div class="hitarea collapsable-hitarea"></div>
    								<img alt="" src="<?php echo site_url()?>assets/js/tree/images/icon-place.png" style="width: 25px;">
                                    <?php echo $le->name?>
    								<ul>
                                        <?php foreach($le->district AS $ell=>$lle):?>
    									<li class="last" style="padding-left: 30px">
                                        <?php echo $lle->type.' '.$lle->name?>
                                            <ul>
                                            <?php foreach($lle->address AS $ul=>$lu):?>    
            									<li class="last">
                                                <b><?php echo $lu->name.' - '.stripslashes($lu->address)?>
												</b>
            										<ul>
                                                        <?php foreach($lu->device AS $ull=>$llu):?> 
                    									<li class="last">
														
														<a href="<?php echo site_url('device-detail/'.$llu->id)?>">
														
                                                        <?php echo $llu->namedevice.'  [ '.$llu->mac.' ]</a> '?>
                    										<img alt="" src="<?php echo site_url()?>assets/js/tree/images/<?php if((time()- $llu->time_update) >= 300):?>offline<?php else:?>online<?php endif;?>.png"/>&nbsp;&nbsp;
                                                            <a style="padding: 5px 7px!important" class="btn btn-info" href="<?php echo $llu->url_homepage.'?res=notyet&uamip=10.20.32.1&uamport=3990&challenge=dc11415464105f45350c714a554570ea&called=78:A3:51:01:B9:8D&mac=admin&ip=10.20.32.5&nasid='.$llu->nasid.'&sessionid=551b4a4a00000002&userurl=wicity.vn&md=F30685413AE549565FA4392F944F8AB8';?>" target="_blank"><i class="fa fa-share"></i></a>
															<a style="padding: 5px 7px!important" class="btn btn-info" href="<?php echo $baseurl.'device?type=edit&id='.$llu->id;?>" target="_blank"><i class="fa fa-cog"></i></a>
                    									</li>
                                                        <span style="margin-left: 16px;"><?php echo 'Online cuối : '.date('H:i:s d/m/Y', $llu->time_update);?></span><br /><br />
                                                        <?php endforeach;?>
                    								</ul>
            									</li>
                                                <?php endforeach;?>
            								</ul>
    									</li>
                                        <?php endforeach;?>
    								</ul>
    							</li>
                            <?php endforeach;?>
						</ul>
					</div>
				</div>
			</div>
        </div>
	</div>
</div>
<script>
if( $('#province').val() != null && $('#province').val() != '' ){
	//alert('lên');
	var districtid = '<?php echo @$districtid;?>';
	//alert('lên'+districtid);
	$.ajax({
		type: 'get',
		url: '<?php echo site_url('index-list-district');?>',
		data: ({ province: $('#province').val(),
			district: districtid
		}),
		success: function(data_)
		{
			//alert(data_);
			$("#district").html(data_);
		}
   });
}
$('#province').change(function(){
	var province = $('#province').val();
	if( province != null && province != '' ){
		$.ajax({
			type: 'get',
			url: '<?php echo site_url('index-get-district');?>',
			data: ({province: province}),
			success: function(data_)
			{
				$("#district").html(data_);
			}
	   });
	}
});
</script>
